﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MadPropsDemo.RecipeEditor;
using MadPropsDemo.RecipeEditor.Model;

namespace MadPropsDemo.Tests.RecipeEditorTests
{
    public class RecipeEditorTestBase
    {
        protected ViewModel viewModel;
        protected FakeDialogService fakeDialogService;
        protected FakeRecipeService fakeRecipeService;

        protected const string ExpectedDialogFilter = "Recipe Files|*.RECIPE";

        [TestInitialize]
        public void Setup()
        {
            viewModel = new Builder().BuildVM();

            fakeDialogService = new FakeDialogService();
            ReflectionUtils.ReplaceMember(viewModel.Commands, fakeDialogService);

            fakeRecipeService = new FakeRecipeService();
            ReflectionUtils.ReplaceMember(viewModel.Commands, fakeRecipeService);

            OnSetup();
        }

        protected virtual void OnSetup()
        {
        }

        protected string RecipeName
        {
            get { return viewModel.TheRecipe.Name.Value; }
            set { viewModel.TheRecipe.Name.Value = value; }
        }

        protected bool HasUnsavedChanges
        {
            get { return !string.IsNullOrEmpty(viewModel.UnsavedChangesText.Value); }
        }

        protected Ingredient SelectedIngredient
        {
            get { return viewModel.TheSelectedIngredient; }
        }
    }
}
